﻿using StockDashboard.DL.Yahoo;
using StockDashboard.Model;
using StockDashboardWeb;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Web;

namespace AG.Apps.WebServices
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    [AspNetCompatibilityRequirements(RequirementsMode =
     AspNetCompatibilityRequirementsMode.Allowed)]
    public class StockDashboardService : IStockDashboardService
    {
        public List<QuoteInfo> GetQuotes(string symbol, System.DateTime startDate, System.DateTime endDate, String connectionString)
        {
            DALQuote dalQuote = new DALQuote(connectionString);

            return dalQuote.GetQuotesItemsYahooFinance(symbol, startDate, endDate);
        }

        public void RefreshAll(String connectionString)
        {
            DALQuote dalQuote = new DALQuote(connectionString);

            dalQuote.RefreshAllQuotes();
        }
        public void RefreshQuotes(String symbol,  String connectionString)
        {
            DALQuote dalQuote = new DALQuote(connectionString);

            dalQuote.RefreshQuotes(symbol);
        }

        public string GetQuoteLatest(String symbol, String connectionString)
        {
            DALQuote dalQuote = new DALQuote(connectionString);

            return dalQuote.GetQuoteLatest(symbol);
        }

    }
}
